<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

    <title>操行详细信息</title>
    <link href="../css/bootstrap-cerulean.css" rel="stylesheet">
    <link href="../css/charisma-app.css" rel="stylesheet">
    <style type="text/css">
        body {
            padding-bottom: 40px;
        }

        .sidebar-nav {
            padding: 9px 0;
        }
    </style>

    <script src="http://lib.sinaapp.com/js/jquery/2.2.4/jquery-2.2.4.min.js"></script>
    <script src="../js/common/public.js"></script>
    <script src="../js/base64.js"></script>
    <script src="../js/bootstrap-modal.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            var urlMsg = parseUrl(window.location.search);
            $("#token").val(urlMsg.token);
            if (urlMsg.token != null) {
                var token = decode(urlMsg.token);
                token=token.substring(0,token.length-1);
            }
            var html = $.ajax({
                type: "GET",
                url: "http://localhost:1068/admin/student/findStudentByStudentNumber?token="+token+"&studentNumber="+urlMsg.studentNumber,
                async: false
            }).responseText;
            var result = eval('(' + html + ')');
            if (result.code != 200) {
                alert(result.msg)
            } else {
                $("#studentNumber").html(result.data.studentNumber);
                $("#studentName").html(result.data.name);
                $("#studentClass").html(result.data.classNumber);
                $("#score").html(result.data.score);
                if (result.data.studentScoreList!=null){
                    for (index in result.data.studentScoreList) {
                        addStudentScoreTable(result.data.studentScoreList[index].id,result.data.studentScoreList[index].studentNumber,result.data.studentScoreList[index].name,
                            result.data.studentScoreList[index].finallyScore,result.data.studentScoreList[index].reason,result.data.studentScoreList[index].remark
                        ,result.data.studentScoreList[index].page,result.data.studentScoreList[index].operator);
                        $('#updateScore'+ result.data.studentScoreList[index].id+'').attr('href','editStudentScore.html?token='+urlMsg.token+'&id='+result.data.studentScoreList[index].id+'&oldScore='+result.data.studentScoreList[index].finallyScore);
                    }
                }
            }
        });
        function addStudentScoreTable(id,studentNumber,name,finallyScore,reason,remark,page,operator) {
            $("#studentScoreList tbody").append(" <tr class='odd'>\n" +
                "<td class=' sorting_1'>"+studentNumber+"</td>\n" +
                "<td class='center '>"+name+"</td>\n" +
                "<td class='center '>"+finallyScore+"</td>\n" +
                "<td class='center '>"+reason+"</td>\n" +
                "<td class='center '>"+remark+"</td>\n" +
                "<td class='center '>"+page+"</td>\n" +
                "<td class='center '>"+operator+"</td>\n" +
                "<td class='center '>\n" +
                "    <a id='updateScore"+id+"' class='btn btn-info'\n" +
                "       href=''>\n" +
                "        <i class='icon-edit icon-white'></i>\n" +
                "        编辑\n" +
                "    </a>\n" +
                "    <a id='deleteScore"+id+"' class='btn btn-danger'\n" +
                "       href='javascript:void(0);' onclick='deleteScore(id="+id+",this);'>\n" +
                "        <i class='icon-trash icon-white'></i>\n" +
                "        删除\n" +
                "    </a>\n" +
                "</td>\n" +
                "  </tr>");

        }

        function deleteScore(id,a) {
            if(window.confirm('删除操作不可逆，确定要删除吗？')){
                var urlMsg = parseUrl(window.location.search);
                $("#token").val(urlMsg.token);
                if (urlMsg.token != null) {
                    var token = decode(urlMsg.token);
                    token=token.substring(0,token.length-1);
                }
                var html = $.ajax({
                    type: "DELETE",
                    url: "http://localhost:1068/admin/studentScore/deleteScore?token="+token+"&id="+id,
                    async: false
                }).responseText;
                var result = eval('(' + html + ')');
                if (result.code != 200) {
                    alert(result.msg)
                } else {
                    alert("删除成功！")
                    var score =   $("#score").html();
                    $("#score").html(score-result.data);
                    $(a).parent().parent().remove();
                }
            }else{
               // alert("取消");
                return false;
            }
        }
    </script>
</head>

<body>
<div class="container-fluid"
     style="padding-left:0px;padding-right:2px;">
    <div class="row-fluid">
        <div id="content" class="span10" style="width:100%;">
            <div class="row-fluid sortable">
                <div class="box span12">
                    <div class="box-header well">
                        <h2>
                            <i class="icon-user"></i>操行详细信息
                        </h2>
                    </div>
                    <div class="box-content">

                        <div id="DataTables_Table_0_wrapper" class="dataTables_wrapper">
                            <table
                                    class="table table-striped table-bordered bootstrap-datatable datatable dataTable"
                                    id="">
                                <thead>
                                <tr>
                                    <th class="sorting_asc" rowspan="1" colspan="1" style="width: 163px;">学生学号</th>
                                    <th class="sorting" rowspan="1" colspan="1" style="width: 115px;">学生姓名</th>
                                    <th class="sorting" rowspan="1" colspan="1" style="width: 281px;">所在班级</th>
                                    <th class="sorting" rowspan="1" colspan="1" style="width: 83px;">操行总分</th>
                                </tr>
                                </thead>

                                <tbody>
                                <tr class="odd">
                                    <td class=" sorting_1" id="studentNumber"></td>
                                    <td class="center " id="studentName"></td>
                                    <td class="center " id="studentClass"></td>
                                    <td class="center " id="score"></td>

                                </tr>
                                </tbody>
                            </table>

                            <table
                                    class="table table-striped table-bordered bootstrap-datatable datatable dataTable"
                                    id="studentScoreList">

                                <thead>
                                <tr>
                                    <th class="sorting_asc" rowspan="1" colspan="1" style="width: 113px;">学生学号</th>
                                    <th class="sorting_asc" rowspan="1" colspan="1" style="width: 113px;">学生姓名</th>
                                    <th class="sorting" rowspan="1" colspan="1" style="width: 45px;">分值</th>
                                    <th class="sorting" rowspan="1" colspan="1" style="width: 131px;">部门</th>
                                    <th class="sorting" rowspan="1" colspan="1" style="width: 300px;">原因</th>
                                    <th class="sorting" rowspan="1" colspan="1" style="width: 83px;">页码</th>
                                    <th class="sorting" rowspan="1" colspan="1" style="width: 83px;">操作者</th>
                                    <th class="sorting" rowspan="1" colspan="1" style="width: 179px;">操作</th>
                                </tr>
                                </thead>

                                <tbody>
                                   
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>